//
// Created by 86155 on 2025/4/16.
//

#ifndef LLVM_FESUBTARGET_H
#define LLVM_FESUBTARGET_H
#include "FeInstrInfo.h"
#include "FeRegisterInfo.h"
#include "FeFrameLowering.h"
#include "FeISelLowering.h"
#include"llvm/CodeGen/SelectionDAGTargetInfo.h"
#define GET_SUBTARGETINFO_HEADER
#include "FeGenSubtargetInfo.inc"
namespace llvm {
class FeSubtarget : public FeGenSubtargetInfo{
  FeInstrInfo InstrInfo;
  FeRegisterInfo RegInfo;
  FeFrameLowering FrameLowering;
  FeTargetLowering TLI;
public:
  FeSubtarget(const Triple &TT, StringRef CPU, StringRef Features,const TargetMachine &TM); //对应createFeMCSubtargetInfo 引入TargetMachine节点信息

  FeSubtarget &initializeSubtargetDependencies(const Triple &TT,
                                                StringRef CPU,
                                                StringRef FS,
                                                const TargetMachine &TM);

  const FeInstrInfo *getInstrInfo() const override { return &InstrInfo; }//获取指令信息

  const FeRegisterInfo *getRegisterInfo() const override {//获取寄存器信息
    return &RegInfo;
  }
  const FeFrameLowering *getFrameLowering() const override {
    return &FrameLowering;
  }

  const FeTargetLowering *getTargetLowering() const override {
    return &TLI;
  }

  void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
};

}

#endif // LLVM_FESUBTARGET_H
